<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE10" />
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<link rel="stylesheet" href="css/bootstrap.min.css" />
<link rel="stylesheet" href="css/bootstrap-responsive.min.css" /> 
<link href="font-awesome/css/font-awesome.css" rel="stylesheet" />
<title>oec后台管理系统</title>
<style>
 body{
  background: #65cea7 url("image/login-bg.jpg") no-repeat fixed;
 }
 .form-sigin{
    max-width:330px;
    margin:100px auto;
    background:#fff;
    border-radius:5px;
 }
 .form-sigin-heading{
  padding:25px 15px;
  position:relative;
 }
 .form-sigin-heading .sign-title{
  position:absolute;
  top:-60px;
  left:0px;
  width:100%;
  color:#fff;
  text-transform:uppercase;
  font-size:24px;
  
 }
 
 .login-wrap{
  padding:20px;
  position:relative;
  
 }
 .login-wrap p{
  text-align:left;
  font-size:16px;
  color:#b6b6b6;
  }
  .login-wrap input[type="text"],.login-wrap input[type="password"]{
   width:90%;
   margin-bottom:3px;
   background:#eaeaec;
   border-radius:5px;
   padding:10px 5px;
  }
 
  label{
   display:inline-block;
   float:left;
   width:50%;
   
  }
  .btn-sigin{
   background:#6bc5a4;
   font-size:30px;
   color:#fff;
   width:94%;
  padding:10px 5px;
  }
  .registration{
   color:#c7c7c7;
   text-align:center;
   margin-top:15px;
  }
  .registration a{
  color:  #6bc5a4;
  }
  .header ul li{
   list-style:none;
   float:left;
   width:50%;
   text-align:center;
   
  }
  .header ul li a{
   text-decoration:none;
   color:#000;
  }

  .header{
   height:44px;
   
  }
  .content span{
   color:red;
  }
  #att1,#att2{
   height:18px;
   font-size:12px;
   color:red;
  }
</style>
</head>
<body>
<div class="login-body">
 <div class="container">
  <form class="form-sigin"   name='fm'>
   <div class="form-sigin-heading text-center">
     <h1 class="sign-title">管理员登录</h1>
     <img src="image/login-logo.png">
   </div>
   <div class="login-wrap">
     <div class="way" style="display:block">
	  <div><span style="color:red;">*</span><input type="text" autofocus=""  name="id" placeholder="用户名" class="form-control">
	        <div id="att1"></div>
	  </div>
      <div><span style="color:red;">*</span><input type="password" autofocus="" name="pwd" placeholder="密码" class="form-control"></div>
      <div id="att2"></div>
      <div><button type="submit" onclick="return check()" style="margin-left:5px" class="btn btn-lg btn-sigin"><i class="icon-ok"></i>登录</button></div>
     </div>
   </div>
  </form>
 </div>
</div>
<script src="js/jquery.min.js"></script>
<script type="text/javascript">
$("input[name='id']").blur(function(){
	if($(this).val()==""){
		$("#att1").empty();
		$("#att1").append("不能为空");
		return;
	}
})
$("input[name='id']").focus(function(){
		$("#att1").empty();
})

$("input[name='pwd']").blur(function(){
	if($(this).val()==""){
		$("#att2").empty();
		$("#att2").append("不能为空");
		return;
	}
})
$("input[name='pwd']").focus(function(){
		$("#att2").empty();
})
 function check(){
	 var result=false;
	 if($("input[name='id']").val()==""){
			$("#att1").empty();
			$("#att1").append("不能为空");
			return false;
		}
	 if($("input[name='pwd']").val()==""){
			$("#att2").empty();
			$("#att2").append("不能为空");
			return false;
		}
	 $.ajax({
		 url:'<%=request.getContextPath()%>/login?method=check',
		 dataType:'json',
		 type:'post',
		 data:{id:$("input[name='id']").val(),pwd:$("input[name='pwd']").val()},
/* 		 async : false,
 */		 success:function(data){
			 if(data.success){
				 window.open('<%=request.getContextPath() %>/login?method=admin&id='+$("input[name='id']").val(),'_self');
				 result=false;
			 }else{
				 $("#att2").empty();
				 $("#att2").append("用户名或者密码错误，请重新输入");
				 result=false;
			 }
		 }
	 })
	 return result;
 }
</script>
</body>
</html>